from django.utils.deprecation import MiddlewareMixin
from .authentication import authenticate


class AuthenticationMiddleware(MiddlewareMixin):
    def process_request(self, request):
        is_admin_request = request.path.startswith('/admin/')
        if not is_admin_request:
            request.user = authenticate(request)
        return
